<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>lianxi</title>
    <link rel="stylesheet" href="css/personal.css">
    <link rel="stylesheet" href="css/mui.min.css">
    <script src="js/jquery-1.8.3.min.js"></script>
    <script src="js/mui.min.js"></script>
</head>
<body>
<div class="nav"><!--头部-->
    <div class="header">
        <p class="arrows" onclick="window.location.href='../coach-I/coach-me.html'">
            <img src="../public_img/return.png" alt="">
        </p>
        <p class="">个人设置</p>
    </div>
</div><!--nav结束-->

<div class="content"><!--内容-->
    <div class="name">
        <span>头像</span>
        <input type="file" name="file" onchange="UpladFile()" class="file" id="file" size="28"  style="display: none"/>
        <img class="portrait" src="">
    </div>
    <ul class="item_wrap">
        <li>
            <span>姓名</span>
            <input type="text" class="name" placeholder="未设置">
        </li>
            <!--<li>-->
                <!--<span>职业</span>-->
                <!--<input type="text" class="work" placeholder="未设置">-->
            <!--</li>-->
        <li>
            <span>地区</span>
            <input type="text" class="address" placeholder="点击查看">
        </li>
        <li>
            <span>身份证号码</span>
            <input type="text"  style="width: 5.72rem;"  class="id_number" placeholder="未设置">
        </li>

         <li>
            <span>支付宝账号</span>
            <input type="text"  style="width: 5.72rem;"  class="zfb" placeholder="未设置">
        </li>
    </ul>
</div><!--content结束-->


<!--<nav class="base">&lt;!&ndash;底部导航&ndash;&gt;-->
    <!--<a class="active" href="" style="margin-left: 0.001rem">-->
        <!--<span><img src="img/apply.png" alt=""></span>-->
        <!--<span>报名</span>-->
    <!--</a>-->
    <!--<a class="active" href="">-->
        <!--<span class=""><img src="img/teaching.png" alt=""></span>-->
        <!--<span>约教</span>-->
    <!--</a>-->
    <!--<a class="active" href="">-->
        <!--<span><img src="img/exercise.png" alt=""></span>-->
        <!--<span>练题</span>-->
    <!--</a>-->
    <!--<a class="active" href="">-->
        <!--<span><img src="img/personage1.png" alt=""></span>-->
        <!--<span style="color: #f39839">我</span>-->
    <!--</a>-->
<!--</nav>&lt;!&ndash;结束&ndash;&gt;-->

<script src="js/personal.js"></script>
<script src="../jquery.min.js	"></script>
<script>
    $(function () {
        $('.name img').click(function () {
            $('.name input[type=file]').click();
        })
        $('.address').click(function () {
            window.location.href='../distence/distence.html';
        })
        var token=localStorage.phone;
        $.ajax({
            url:"https://newapp.icandrive.cn/api/set.php",
            type:'post',
            dataType:'json',
            data:{token:token},
            success: function (data) {
                console.log(data);
                if(data.status==200){
                    $(data.dataing).each(function () {
                        $('.portrait').attr('src',this.teacher_photo);
                        $('.name').val(this.teacher_name);
                        $('.id_number').val(this.ID_number);
                         $('.zfb').val(this.alipay_account);
                    })
                }
            },
            error: function () {
            }
        })
    })
    var xhr;

    function createXMLHttpRequest() {
        if (window.ActiveXObject) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        } else if (window.XMLHttpRequest) {
            xhr = new XMLHttpRequest();
        }
    }

    function UpladFile() {
        var f=document.getElementById("file").value;
        if(!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(f))
        {
            layer.msg("请选择正确格式的图片");
            return false;
        }
        var token=localStorage.phone;
        var fileObj = document.getElementById("file").files[0];
        var FileController = 'https://newapp.icandrive.cn/api/photo.php?token='+token;
        var form = new FormData();
        form.append("myfile", fileObj);
        createXMLHttpRequest();
        xhr.onreadystatechange = handleStateChange;
        xhr.open("post", FileController, true);
        xhr.send(form);
    }
    function handleStateChange() {
        if (xhr.readyState == 4) {
            if (xhr.status == 200 || xhr.status == 0) {
                var result = xhr.responseText;
                var json = eval("(" + result + ")");
                setTimeout(function(){
                    history.go(0)
                },2000)

            }
        }
    }
</script>

    <script>
    document.addEventListener("plusready", function() {
        // 注册返回按键事件
        plus.key.addEventListener('backbutton', function() {
            window.history.back();
        }, false);
        //此处false代表不退出页面，如果为true回退到上一个一面
    });
</script>
</body>
</html>
